package com.shengtsource.minicat.model;

import com.shengtsource.minicat.util.HttpProtocolUtils;

import java.io.IOException;
import java.io.OutputStream;

public class DemoServletBak extends HttpServlet {
    @Override
    public void doGet(Request request, Response response) throws IOException {
        System.out.println("Demo1 doGet 方法调用");
        String data = "<h1>Hello doGet method Demo1 !</h1>";
        String reposneText = HttpProtocolUtils.getResponseHeader200(data.getBytes().length).concat(data);
        OutputStream outputStream = response.getOutputStream();
        outputStream.write(reposneText.getBytes());
        outputStream.flush();
    }

    @Override
    public void doPost(Request request, Response response) throws IOException {
        System.out.println("doPost 方法调用");
        String data = "<h1>Hello doPost method !</h1>";
        String reposneText = HttpProtocolUtils.getResponseHeader200(data.getBytes().length).concat(data);
        OutputStream outputStream = response.getOutputStream();
        outputStream.write(reposneText.getBytes());
        outputStream.flush();
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destory() throws Exception {

    }
}
